import Vue from 'vue';
import Element from 'element-ui';
import './assets/styles/element-variables.scss';
import '@/assets/styles/index.scss'; // global css
import '@/assets/styles/ruoyi.scss'; // ruoyi css
import '@/assets/styles/xz.scss'; // xz css
import App from './App';
import store from './store';
import router from './router';
import directive from './directive'; // directive
import plugins from './plugins'; // plugins
import {
	download,
	downloadTemplate,
	download_get,
	download_json,
} from '@/utils/request';
import Cookies from 'js-cookie';
// import dayjs from "dayjs";
import { isNull } from '@/utils/validate';
import './assets/icons'; // icon
import './permission'; // permission control
import { getDicts } from '@/api/system/dict/data';
import { getConfigKey, updateConfigByKey } from '@/api/system/config';
import { checkPermi, checkRole } from '@/utils/permission';
import {
	parseTime,
	resetForm,
	addDateRange,
	selectDictLabel,
	selectDictLabels,
	handleTree,
} from '@/utils/ruoyi';

let Base64 = require('js-base64').Base64;
Vue.prototype.Base64 = Base64;
// encode
// decode
// var quarterOfYear = require("dayjs/plugin/quarterOfYear");
// dayjs.extend(quarterOfYear);
// dayjs.locale("zh-cn");

import mitt from 'mitt';

const emitter = mitt();
Vue.prototype.$emitter = emitter;
// 分页组件
import Pagination from '@/components/Pagination';
// 自定义表格工具组件
import RightToolbar from '@/components/RightToolbar';
// 富文本组件
import Editor from '@/components/Editor';
// 文件上传组件
import FileUpload from '@/components/FileUpload';
// 图片上传组件
import ImageUpload from '@/components/ImageUpload';
// 图片预览组件
import ImagePreview from '@/components/ImagePreview';
import ImageCommon from '@/components/ImageCommon';
// 字典标签组件
import DictTag from '@/components/DictTag';
// 头部标签组件
import VueMeta from 'vue-meta';
// 字典数据组件
import DictData from '@/components/DictData';
// 表格分页
import TablePage from '@/components/TablePage';
// 按钮
import EButton from '@/components/EButton';
// 工单模板ws
import DetailsPage from '@/components/DetailsPage';
// 工单模板yq
import WorkTemplate from '@/components/WorkTemplate';
//
//开关
import ESwitch from '@/components/ESwitch/index.vue';

// 搜索栏
import SearchForm from '@/components/SearchContent/searchForm.vue';
//公共容器
import CommonContainer from '@/components/CommonContentInfo/index.vue';
//审批流程记录
import FlowRecord from '@/components/FlowRecord/index.vue';
//新增页面
import CommonPage from '@/components/CommonPage/index.vue';
//逾期时长
import SearchTime from '@/components/SearchTime';
// 过长显示省略号
import TooltipDiv from '@/views/quota/forecast/chunk/tooltipDiv';
//金额输入框
import AmountInput from "@/components/AmountInput/index.vue";
// 全局方法挂载
Vue.prototype.getDicts = getDicts;
Vue.prototype.getConfigKey = getConfigKey;
Vue.prototype.updateConfigByKey = updateConfigByKey;
Vue.prototype.parseTime = parseTime;
Vue.prototype.resetForm = resetForm;
Vue.prototype.addDateRange = addDateRange;
Vue.prototype.selectDictLabel = selectDictLabel;
Vue.prototype.selectDictLabels = selectDictLabels;
Vue.prototype.download = download;
Vue.prototype.downloadTemplate = downloadTemplate;
Vue.prototype.checkPermi = checkPermi;
Vue.prototype.checkRole = checkRole;
Vue.prototype.download_get = download_get;
Vue.prototype.download_json = download_json;

Vue.prototype.handleTree = handleTree;
Vue.prototype.$mmvImageUrl = require('@/utils/filters').mmvImageUrl;

// 注册全局过滤器
import * as filters from '@/utils/filters';

for (const key in filters) {
	Vue.filter(key, filters[key]);
}

// Vue.prototype.$dayjs = dayjs;
Vue.prototype.isNull = isNull;
import * as utils from '@/utils/utils';

for (const key in utils) {
	Vue.prototype[key] = utils[key];
}
// Vue.prototype.$dayjs = dayjs;

// 全局组件挂载
Vue.component('DictTag', DictTag);
Vue.component('Pagination', Pagination);
Vue.component('RightToolbar', RightToolbar);
Vue.component('Editor', Editor);
Vue.component('FileUpload', FileUpload);
Vue.component('ImageUpload', ImageUpload);
Vue.component('ImagePreview', ImagePreview);
Vue.component('TablePage', TablePage);
Vue.component('EButton', EButton);
Vue.component('DictTag', DictTag);
Vue.component('Pagination', Pagination);
Vue.component('RightToolbar', RightToolbar);
Vue.component('Editor', Editor);
Vue.component('FileUpload', FileUpload);
Vue.component('ImageUpload', ImageUpload);
Vue.component('ImagePreview', ImagePreview);
Vue.component('TablePage', TablePage);
Vue.component('EButton', EButton);
Vue.component('DetailsPage', DetailsPage);
Vue.component('ESwitch', ESwitch);
Vue.component('SearchForm', SearchForm);
Vue.component('CommonContainer', CommonContainer);
Vue.component('ImageCommon', ImageCommon);
Vue.component('WorkTemplate', WorkTemplate);
Vue.component('FlowRecord', FlowRecord);
Vue.component('CommonPage', CommonPage);
Vue.component('SearchTime', SearchTime);
Vue.component('TooltipDiv', TooltipDiv);
Vue.component("AmountInput", AmountInput);

Vue.use(directive);
Vue.use(plugins);
Vue.use(VueMeta);
DictData.install();

import FlowRecordA from '@/components/FlowRecord/indexA.vue';
Vue.component('A-FlowRecord', FlowRecordA);
import VueCompositionAPI from '@vue/composition-api';

Vue.use(VueCompositionAPI);
import imagePreview from '@/components/ImagePreview/preview.js';

Vue.prototype.$imagePreview = imagePreview;

// 选择列表
import SelectDialog from '@/views/finance/reimburs/template/index.js';

Vue.prototype.$SelectDialog = SelectDialog;
// 上传
import UploadDialog from '@/components/uploadDialog/index.js';

Vue.prototype.$UploadDialog = UploadDialog;
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

// 修改 el-dialog 默认点击遮照为不关闭
Element.Dialog.props.closeOnClickModal.default = false;

Vue.use(Element, {
	size: Cookies.get('size') || 'small', // set element-ui default size
});

Vue.config.productionTip = false;

var _ = require('lodash');
Vue.prototype._ = _;

import dayjs from 'dayjs'; // ES 2015
dayjs().format();
var calendar = require('dayjs/plugin/calendar');
dayjs.extend(calendar);
var duration = require('dayjs/plugin/duration');
dayjs.extend(duration);
var isSameOrAfter = require('dayjs/plugin/isSameOrAfter');
dayjs.extend(isSameOrAfter);
var isSameOrBefore = require('dayjs/plugin/isSameOrBefore');
dayjs.extend(isSameOrBefore);
Vue.prototype.$dayjs = dayjs;
export { dayjs };

import mixins from './utils/mixin';

Vue.mixin(mixins);

new Vue({
	el: '#app',
	router,
	store,
	render: h => h(App),
	beforeCreate() {
		Vue.prototype.$bus = this; //安装全局事件总线
	},
});
